package ru.beta2.testyard.engine.points;

import ru.beta2.testyard.engine.ScriptPoint;

/**
 * User: Inc
 * Date: 19.06.2008
 * Time: 3:01:44
 */
public class SendPoint extends ScriptPoint
{

    private final int player;
    private final Object message;
    private final String channel;

    public SendPoint(int player, Object message)
    {
        this(player, null, message);
    }

    public SendPoint(int player, String channel, Object message)
    {
        this.player = player;
        this.message = message;
        this.channel = channel;
    }

    public void exec()
    {
        if (channel == null) {
            System.out.println("Send session message: " + message);
            link().sendSessionMessage(player, message);
        }
        else {
            System.out.println("Send channel message: " + message);
            link().sendChannelMessage(player, channel, message);
        }
    }

    public boolean execChildren()
    {
        return true;
    }
}
